﻿using System;
using System.Collections.Generic;
using System.Data;
using DAL;
using Entities;

namespace BLL
{
    public class BLL_Faqs
    {
        private DAL_Faqs dal_Faqs = new DAL_Faqs();

        public DataTable Get_Faqs_All()
        {
            return dal_Faqs.Get_Faqs_All();
        }

        public DataTable Get_Faqs_Top()
        {
            return dal_Faqs.Get_Faqs_Top();
        }

        public DataTable Get_Faqs_ByID(int p_faq_id)
        {
            return dal_Faqs.Get_Faqs_ByID(p_faq_id);
        }

        public DataSet Get_FaqDetail(int p_faq_id)
        {
            return dal_Faqs.Get_FaqDetail(p_faq_id);
        }

        public Int32 InsertFaq(Faqs pFaqs)
        {
            return dal_Faqs.InsertFaq(pFaqs);
        }

        public bool UpdateFaq(Faqs pFaqs)
        {
            return dal_Faqs.UpdateFaq(pFaqs);
        }

        public bool DeleteFaqs(Int32 p_faq_id)
        {
            return dal_Faqs.DeleteFaq(p_faq_id);
        }

        public List<Faqs> Lst_Faqs(DataTable pdt)
        {
            List<Faqs> lstReturn = new List<Faqs>();
            if (pdt != null && pdt.Rows.Count > 0)
            {
                foreach (DataRow dr in pdt.Rows)
                {
                    Faqs obj_Faqs = new Faqs();
                    obj_Faqs.FAQ_ID = Convert.ToInt32(dr["Faq_id"]);
                    obj_Faqs.TITLE = Convert.ToString(dr["Title"]);
                    obj_Faqs.QUESTION = Convert.ToString(dr["Question"]);
                    obj_Faqs.ANSWER = Convert.ToString(dr["Answer"]);
                    obj_Faqs.EMAIL = Convert.ToString(dr["Email"]);
                    obj_Faqs.CREATE_DATE = (dr["Create_date"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(dr["Create_date"]));

                    lstReturn.Add(obj_Faqs);
                }
            }
            return lstReturn;
        }
    }
}
